#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <unistd.h>
#include<math.h>

#include<iostream>
#include<vector>

using namespace std;

void whiteword(void);
int infor(int older);
int fbl(void);
float absent(float a);

void dismidpoint(float x1,float y1,float x2,float y2);
void disptol(float k,float b,float x0,float y0);
void distance(float x1,float y1,float x2,float y2);
void par3(float x1,float y1,float x2,float y2,float x3,float y3);
//int equals(char* str1,char* str2);
/*int equals(char* str1,char* str2)
{
	
	int i=0;
	if(str1==0 || str2==0)
		return 0;
	if(str1==str2)
		return 1;
	for(;str1[i]!='\0';i++) {
		if(str1[i]!=str2[i]) {
			return 0;
		}
		if(str2[i]=='\0'){
			return 0;
		}
	}
	if(str2[i]=='\0')
		return 1;
	else
		return 0;
}*/


void whiteword(void)
{
	printf("\033[0m");
}

int fbl(void)
{
	float k;
	float y;
	float x;
	int s;
	cout<<"Please input the time number of operation\t";	
	cin>>s;
	
	cout<<endl<<"scale factor:";
	cin>>k;
	if(k==0)
	{
		cout<<"Error"<<endl;
	}
	else
	{
		int i;
		for(i=0;i<s;i++) 
		{
			cout<<"Independent variable:"<<endl;
			cin>>x;
			y=k/x;
			cout<<"Dependent variable:"<<y<<endl;
	printf("\033[0;33m");
			if(k>0)
			{
				printf("The image of the function is a hyperbola that ");
				printf("passes the first and the third quadrent.\n");
				printf("In each quadrent,the dependent valuable "
				"decreases with the increase of the independent valuable."); 
			}else
			{
				printf("The image of the function is a hyperbola that ");
				printf("passes the second and the fourth quadrent.\n");
				cout<<"In each quadrent,the dependent valuable "
				"insreases with the increase of the independent valuable."<<endl; 
			}
	printf("\033[0m");
		}
	}
	
	
}

void dismidpoint(float x1,float y1,float x2,float y2)
{
	float x3=(x1+x2)/2;float y3=(y1+y2)/3;
	cout<<"So the middle point coordinates of the line segment are:";
	cout<<x3<<y3;
}

void disptol(float k,float b,float x0,float y0)
{	
	//y=k*x+b -> k*x-y+b=0
	float he=k*k+1;(double)(he);
	double di=sqrt(he);
	float s=k*x0+y0+b;(double)(s);
	double a=s/he;
	cout<<"The distance from the point to the line is"<<s<<endl;
}

void distance(float x1,float y1,float x2,float y2)
{
	float cx=(x2-x1);float cy=(y1-y2);
	(double)(cx);	(double)(cy);
	cx=cx*cx;cy=cy*cy;
	double he=cx+cy;
	cout<<"The distance from the two points is"<<sqrt(he)<<endl;

}

float absent(float a)
{
	if(a==0.0)
	{return 0.0;}
	else if(a<0.0)
	{return (0.0-a);}
	else {return a;}
}
void par3(float x1,float y1,float x2,float y2,float x3,float y3)
{
	if((x1==x2&&y1==y2)||(x1==x3&&y1==y3)||(x2==x3&&y2==y3))
	{
	cout<<"No parallelogram.\n";
	}
	else 
	{
	float cx=absent(x2-x1);
	float cy=absent(y2-y1);
	float x4=cx+x3;
	float y4=cy+y3;
	cout<<"The point that can make a parallelogram with those 3 points is:"<<endl;
	cout<<"\t\t ("<<x4<<","<<y4<<")\n";
	}
}
